package com.biz.primus.model.order.enums;

import com.biz.primus.common.enums.EnumerableValue;
import com.biz.primus.common.enums.converter.BaseEnumValueConverter;

/**
 * 订单状态<p>
 * WAIT_PAY：待付款,
 * WAIT_SEND：待发货,
 * WAIT_RECEIVE：待收货,
 * WAIT_EVALUATION：待评价,
 * FINISHED：订单完成,
 * CANCELED：取消,
 * AFTER_SALE：售后中,
 * FINISHED_AFTER_SALE：售后完成
 * </p>
 *
 * @author Tiger Feng
 * @date 2017年10月28日
 */
public enum OrderState implements EnumerableValue {
//    pre_order(0, "待支付"),
//    ordering(5, "待发货"),
//    delivered(10, "已发货"),
//    received(15, "已签收"),
//    finished(50, "订单完成"),
//    expired(-5, "过期未支付"),
//    canceled(-10, "已关闭"),
//    reject(-13, "拒收"),
//    closed(-99, "系统关闭"),
//
//    apply_return(-15, "申请退货"),
//    sales_returning(-20, "退货中"),
//    turn_down(-23, "审核不通过"),
//    refunded(-25, "退款完成"),
//    push_fail(-30, "推单失败"),

    WAIT_PAY(-1, "待付款"),
    WAIT_SEND(0, "待发货"),
    WAIT_RECEIVE(5, "待收货"),
    WAIT_EVALUATION(10, "待评价"),
    FINISHED(20, "订单完成"),
    CANCELED(30, "取消"),
    AFTER_SALE(50, "售后中"),
    FINISHED_AFTER_SALE(55, "售后完成"),;
//    RECEIVED(15, "已签收"),
//    ORDER_FINISHED(50, "订单完成"); //评价后设置订单为完成状态


    public static class Converter extends BaseEnumValueConverter<OrderState> {
    }


    public final int value;

    public final String desc;

    OrderState(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public int getValue() {
        return value;
    }

    public static OrderState getByValue(int value) {
        for (OrderState orderState : values()) {
            if (value == orderState.value) {
                return orderState;
            }
        }
        return null;
    }
}